Results 1 to 3 of 3

Thread: Calculate age age calculator

  1. #1
    Senior Hostboard Member LonArcvarden's Avatar
    Join Date
    June 20th, 2022
    Posts
    318
    Follows
    0
    Following
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    1 Post(s)

    Calculate age age calculator

    Code:
    DOB := "02/15/1998"   ; input the birthdate   (the format is MM/DD/YYYY)
    
    
    
    
    StringSplit, dates, DOB, `/    ; chops up DOB
    
    
    MAct:= A_MM    ; setting variable for current month
    AAct:= A_YYYY  ; setting variable for current year
    DAct:= A_DD  ; setting variable for current day
    
    
    MNac:= dates1  ; setting variable for birth month
    ANac:= dates3   ; setting variable for birth year
    DNac:= dates2  ; setting variable for birth day
    sleep, 10   ; chilling for a sec
    If (MAct<MNac)
    {
    Age:=AAct-ANac-1
    }
    If (MAct=MNac and DAct<DNac)
    {
    Age:=AAct-ANac-1
    }
    If (MAct=MNac and DAct>=DNac)
    {
    Age:=AAct-ANac
    }
    If (MAct>MNac)
    {
    Age:=AAct-ANac
    }
    sleep, 100     ; chilling for a sec
    
    
    MsgBox, The age is %age%
    A little while ago I needed a way to calculate age off of knowing a birthdate. Most documentation I found wasn't really working in my case, so after working through what was best for me, I wanted to turn around and share it to hopefully help someone else down the road. Probably not the most elegant way of doing things and it could be reduced somewhat but I think it is stable and pretty easy to understand

  2. #2
    Senior Hostboard Member princemeraj's Avatar
    Join Date
    February 23rd, 2023
    Posts
    233
    Follows
    0
    Following
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)

    Re: Calculate age age calculator

    If you’re looking to calculate age with AutoHotkey, I'd check out skyth540’s script for simplicity. For a web-dependent option, TheDewd shared an interesting alternative that pulls data online.

  3. #3
    Hostboard Member ayawoalhassan's Avatar
    Join Date
    March 30th, 2023
    Posts
    77
    Follows
    0
    Following
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)

    Re: Calculate age age calculator

    Your script for calculating age sounds useful. I've had success using an online tool that accurately provides an exact chronological age by simply entering a birthdate. The tool accounts for leap years and can even project future ages. It's been handy when I needed quick results without coding. Maybe give it a try to see how it complements your scripting approach.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •